package friend.dao;



import java.sql.*;

import com.example.friend.pojo.User;
import com.example.frined.utils.JDBCUtils;

public class UserDAO {

	public int insert(User user) throws SQLException
	{
		// 1. ��ȡ����
		Connection conn = JDBCUtils.getConnection();
		
	
		String sql = "insert into user values (null,?,?,?,?,?,?,?,?,?,?)";
		PreparedStatement stmt = conn.prepareStatement(sql);
		
		stmt.setString(1, user.getUsername());
		stmt.setString(2, user.getPassword());
		stmt.setString(3, user.getBirthday());
		stmt.setString(4, user.getTel());
		stmt.setInt(5, user.getAge());
		stmt.setString(6, user.getGender());
		stmt.setString(7, user.getLikes());
		stmt.setString(8, user.getStatus());
		stmt.setInt(9, user.getEdu());
//		stmt.setString(1, user.getUsername());
//		stmt.setString(2, user.getPassword());
//		
//		
//		
//		
//		stmt.setString(7, user.getQq());
//		
//		
//		stmt.setString(10, user.getIntro());
		
		// 3. ִ�в����
		int result = stmt.executeUpdate();
		
		// 4. �ͷ���Դ
		JDBCUtils.destory(conn, stmt, null);
		
		return result;
		
	}
}
